<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Show Stars</title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script>
        function makeStars() {
            $("#showPlace").css("display","");
            var lines=$("#stars").val();
            var starStr="";
            for(var i=0;i<lines;i++){
                for(var j=0;j<lines-i;j++){
                    starStr+="&nbsp;";
                }
                for(var j=0;j<=i;j++){
                    if(j>=1&&j<=i-1){
                        starStr+="&nbsp;&nbsp;";
                    }else{
                        starStr+="&nbsp;*";
                    }
                }
                starStr+="<br/>";
            }
            for(var i=0;i<lines-1;i++){
                for(var j=0;j<=i+1;j++){
                    starStr+="&nbsp;";
                }
                for(var j=0;j<lines-i-1;j++){
                    if(j>=1&&j<lines-i-2){
                        starStr+="&nbsp;&nbsp;"
                    }else{
                        starStr+="&nbsp;*";
                    }
                }
                starStr+="<br/>";
            }
            $("#showPlace").html(starStr);
            $("#stars").css("display","none");
            $("#showClick").css("display","none");
            $("#tips").html("效果如下");
        }
        function ifYouWantToTryMore() {
            if(confirm("再来一次吗")){
                $("#stars").css("display","");
                $("#showClick").css("display","");
                $("#tips").html("你要几行星星");
                $("#showPlace").css("display","none");
            }
        }
    </script>
</head>
<body>
    <span id="tips">你要几行星星</span>:<input id="stars" name="stars" type="text"/><br/>
    <input id="showClick" type="button" value="星星出现" onclick="makeStars()"><br/>
    <div id="showPlace" onclick="ifYouWantToTryMore()"></div>
</body>
</html>